Skip to content

fix: propagate OutputCheckError to caller instead of silently returning#7478

Closed
Yanhu007 wants to merge 1 commit intoagno-agi:mainfrom
Yanhu007:fix/output-check-error-propagation
Closed

fix: propagate OutputCheckError to caller instead of silently returning#7478
Yanhu007 wants to merge 1 commit intoagno-agi:mainfrom
Yanhu007:fix/output-check-error-propagation

Conversation

@Yanhu007
Copy link
Copy Markdown

Summary

Fixes #7414

OutputCheckError raised inside output_validation_post_hook is caught internally by the run methods and returned as a normal RunResponse with status=error. This means the documented try/except OutputCheckError pattern never works:

# This except block is NEVER reached (before this fix)
try:
    result = await agent.arun(input="...")
except OutputCheckError as e:
    print(f"Validation failed: {e}")  # Dead code

Changes

Changed return run_responseraise in the except (InputCheckError, OutputCheckError) handler of all four non-streaming run methods:

Method Type
_run sync
_arun async
_continue_run sync continuation
_acontinue_run async continuation

Session cleanup and error logging are preserved before the re-raise. The exception object (with run_output, check_trigger, etc.) is propagated intact.

Streaming methods (_run_stream, _arun_stream, etc.) still return the error response since exceptions can't meaningfully propagate mid-stream iteration.

OutputCheckError raised in output_validation_post_hook is caught
internally and returned as a normal RunResponse with error status.
This means try/except OutputCheckError never reaches the except
block, contradicting the documented usage pattern.

Re-raise InputCheckError/OutputCheckError after cleanup/logging
in all four non-streaming run methods:
- _run (sync)
- _arun (async)
- _continue_run (sync continuation)
- _acontinue_run (async continuation)

Streaming methods (_run_stream, _arun_stream, etc.) still return
the error response since exceptions can't propagate mid-stream.

Fixes agno-agi#7414
@github-actions
Copy link
Copy Markdown
Contributor

PR Triage

A few things to address before this PR can be reviewed:

Missing tests: This PR modifies source code but does not include any test changes. Please add or update tests to cover your changes.


Possible duplicate: The following open PRs also reference the same issue(s):

If this is intentional, please explain in your PR description why this approach is preferred. Otherwise, consider collaborating on the existing PR instead.


This PR has been automatically closed. There is already an open PR addressing this issue. If you believe your contribution is valuable, please comment on the original issue explaining your approach and why it might be preferred. A maintainer can reopen this PR if appropriate.

@github-actions github-actions Bot closed this Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] OutputCheckError not raised to caller in post-hook output validation — caught internally and logged instead

1 participant